package com.situ.mall.service.Impl;

import com.situ.mall.mapper.CartMapper;
import com.situ.mall.pojo.entity.Cart;
import com.situ.mall.pojo.vo.CartVO;
import com.situ.mall.service.ICartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements ICartService {
    @Autowired
    private CartMapper cartMapper;
    @Override
    public Cart selectByProductId(Integer userId, Integer productId) {
        return cartMapper.selectByProductId(userId, productId);
    }

    @Override
    public void add(Cart cart) {
        cartMapper.insertSelective(cart);
    }

    @Override
    public void updateNum(Cart cart) {
        cartMapper.updateNum(cart);
    }

    @Override
    public List<CartVO> cartListSelectById(Integer userId) {
        return cartMapper.cartListSelectById(userId);
    }

    @Override
    public Integer checkedAll(Integer userId) {
        return cartMapper.checkedAll(userId);
    }

    @Override
    public void update(Cart cart) {
        cartMapper.updateByPrimaryKeySelective(cart);
    }

    @Override
    public void updateAll(Cart cart) {
        cartMapper.updateAll(cart);
    }

    @Override
    public void deleteById(Integer id) {
        cartMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<CartVO> cartListSelectByIdChecked(Integer userId) {
        return cartMapper.cartListSelectByIdChecked(userId);
    }
}
